# -*- coding: utf-8 -*-
import os
from sys import exit


# 遍历 test目录
def get_test_file_list(path):
	file_list = []
	for r, dirs, files in os.walk(path):
		for d in dirs:
			file_list.append(os.path.join(os.path.abspath(r), d))
	return file_list


roots = get_test_file_list('test')
for root in roots:
	os.chdir(root)
	# 运行go测试
	if os.system('go test -v') != 0:
		print('go test failed')
		print('root: ' + root)
		exit(1)

print('all test passed')
